﻿#include "execsqldlg.h"
//#define  TR(text)     QString::fromUtf8(text)       
#define TR(text)      QString::fromLocal8Bit(text) 


ExecSqlDlg::ExecSqlDlg(QWidget *parent)
	: QDialog(parent), m_strEdit("")
{
	this->setWindowTitle(TR("SQL执行"));
	m_labelSql = new QLabel;
	m_labelSql->setText(TR("SQL语句:"));
	
	m_editSql = new QTextEdit;
	
	m_buttonCancel = new QPushButton;
	m_buttonCancel->setText(TR("取消"));

	m_buttonOk = new QPushButton;
	m_buttonOk->setText(TR("确定"));

	m_layOut = new QGridLayout(this);
	m_layOut->addWidget(m_labelSql, 1, 0);
	m_layOut->addWidget(m_editSql, 0, 1,3,3);
	m_layOut->addWidget(m_buttonOk, 4, 1);
	m_layOut->addWidget(m_buttonCancel, 4,  3);
	m_layOut->setSpacing(10);
	m_layOut->setSizeConstraint(QGridLayout::SetFixedSize);

	connect(m_buttonOk, SIGNAL(clicked()), this, SLOT(Slot_ButtonOk()));
	connect(m_buttonCancel, SIGNAL(clicked()), this, SLOT(Slot_ButtonCancel()));
}

ExecSqlDlg::~ExecSqlDlg()
{

}

QString& ExecSqlDlg::GetSqlText()
{
	return this->m_strEdit;
}
void ExecSqlDlg::Slot_ButtonOk()
{
	m_strEdit.clear();
	m_strEdit = m_editSql->toPlainText();
	close();
}

void ExecSqlDlg::Slot_ButtonCancel()
{
	m_strEdit.clear();
	close();
}


